package com.cy.pj.arithmetic.contoller;

import com.cy.pj.common.pojo.ResponseResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;

@Validated
@RestController
public class ArithmeticController {

    @RequestMapping("/doCompute/{n1}/{n2}")
    public ResponseResult doCompute(@PathVariable Integer n1,@Pattern(regexp = "^-[1-9][0-9]*||[1-9][0-9]{0,3}$") @PathVariable String n2){
//        if(n2==0){throw new RuntimeException("除数不能为0");}
        Integer integer = Integer.valueOf(n2);
        Integer result=n1/integer;
        return new ResponseResult("result id"+result);
    }
}
